#include<iostream>
#include<climits>
using namespace std;
const int N=1e5+10;
int a[N];
int main()
{
	int n;cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}

	int left=1,right=1;
	int k=0;
	int ret=INT_MIN;
	while(right<=n)
	{
		k+=a[right];
		while(2*k>=sum)
		{
			ret=max(ret,sum-k);
			k-=a[left];
			left++;
		}
		ret=max(ret,k);
		right++;
	}
	cout<<ret<<endl;
}